<extend name="Layout:layout"/>

<block name="css">
	<link rel="stylesheet" href=""></block>

<block name="srcjs">
	<script type="text/javascript" src=""></script>
</block>

<block name="content">

	<h1>修改密码</h1>
	<hr>

	<form class="form-horizontal" role="form" id="modifyPwdForm" method="post">

		<div class="form-group">
			<label for="username" class="col-sm-2 control-label">用户名</label>
			<div class="col-sm-8">
				<input type="text" class="input-read" id="username" name="username" readonly="true" value="{$_SESSION['current_user']['username']}"></div>
		</div>

		<div class="form-group">
			<label for="oldPassword" class="col-sm-2 control-label">旧密码</label>
			<div class="col-sm-8">
				<input type="password" class="form-control" id="oldPassword" name="oldPassword" required="required"></div>
		</div>

		<div class="form-group">
			<label for="newPassword" class="col-sm-2 control-label">新密码</label>
			<div class="col-sm-8">
				<input type="password" class="form-control" id="newPassword" name="newPassword" required="required"></div>
		</div>

		<div class="form-group">
			<label for="confirmPassword" class="col-sm-2 control-label">确认密码</label>
			<div class="col-sm-8">
				<input type="password" class="form-control" id="confirmPassword" name="confirmPassword" required="required"></div>
		</div>

		<div class="form-group">
			<div class="col-sm-offset-2 col-sm-10">
				<button type="submit" id="btnSubmitPwd" class="btn btn-info">保存</button>
			</div>
		</div>
	</form>

	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>

	<br></block>

<block name="customjs">

	<script type="text/javascript">
	$(function(){
		$("#modifyPwdForm").submit(function(){
			var newPassword = $("#newPassword").val();
			var confirmPassword = $("#confirmPassword").val();

			if( newPassword != confirmPassword){
				alert("密码不一致！");
				return;
			}

			var sendData = {
				'id' : "{$_SESSION['current_user']['id']}",
				'oldPassword' : $("#oldPassword").val(),
				'newPassword' : $("#newPassword").val()
			};

			$.post("{:U('savePwd')}", sendData).done(function(responseData){
				if(responseData.status == 1){
					alert(responseData.info);
					location.href = responseData.jumpUrl;
				}else{
					alert(responseData.info);
				}
			});

			return false;
		});
	});
	</script>

</block>